﻿using System;
using System.Web;

namespace Shinkansen.Web
{
    public class Global : HttpApplication
    {
        /// <summary>
        /// Handles the Start event of the Application control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Application_Start (object sender, EventArgs e)
        {
            SetCustomCrucnhers ();
            SetCustomCryptoProvider ();
        }

        /// <summary>
        /// Sets custom JavaScript/CSS crucnher(s).
        /// </summary>
        private void SetCustomCrucnhers ()
        {
            // NOTE: YahooJsCruncher and YahooCssCruncher come bundled with Shinkansen.
            // You can set them as follows:
            //
            // CruncherBuilder.Current.SetJsCruncher (new YahooJsCruncher ());
            // CruncherBuilder.Current.SetCssCruncher (new YahooCssCruncher ());

            // NOTE: This custom cruncher is included in this sample project. It requires full trust.
            // See GoogleJsCruncher.cs.
            // CruncherBuilder.Current.SetJsCruncher (new GoogleJsCruncher ());
        }

        /// <summary>
        /// Sets a custom cryptographic provider.
        /// </summary>
        private void SetCustomCryptoProvider ()
        {
            // CryptoProviderBuilder.Current.SetCryptoProvider (new CustomCryptoKeyProvider ());
            // ... or ...
            // CryptoProviderBuilder.Current.SetCryptoProvider (new FullTrustMachineKeyProvider ());
        }
    }
}